%@brief Read topology from the file 
%@param [in] fn : Topology file name;
%@return topo : Topology, the user id is translate into position in array cell


function topo=read_topo_file2(fn)
fid=fopen(fn);
id2pos=containers.Map('KeyType','double','ValueType','Double');
pos2id=[];
pos=1;
while ~feof(fid)
    line=fgetl(fid);
    tmp = str2num(line);
    pos2id=[pos2id, tmp(1)];
    id2pos(tmp(1))=pos;
    if length(tmp)>1
        topo{pos}=tmp(2:length(tmp));
    else
        topo{pos}=[];
    end
    pos=pos+1;
end
for i = 1:(pos-1)
    if isempty(topo{i})==true
        continue;
    else
        l=length(topo{i});
        for j=1:l
            uid=topo{i}(j);
            pos=id2pos(uid);
            topo{i}(j)=pos;            
        end        
    end        
end

end
